package Presentation;

//-------------------------------------------------------------------------------------

//import solitaire.controle.* ;
import java.awt.* ;
import java.awt.event.* ;
import javax.swing.* ;

import Controlor.CCarte;

//-------------------------------------------------------------------------------------

public class PCarte extends JPanel {

    protected CCarte controle ;
    protected JLabel face ;
    protected JLabel dos ;
    protected ImageIcon icone ;

    
    public PCarte (final String chaine, final CCarte controle) {
    //public PCarte (final String chaine) {
      this.controle = controle ;
      setLayout (null) ;
      setBackground (Color.yellow) ;
      icone = new ImageIcon ("cartesCSHD/" + chaine + ".gif") ;
      face = new JLabel (icone) ;
      add (face) ;
      face.setLocation (0, 0) ;
      face.setSize (largeur, hauteur) ;
      ImageIcon iconeDos = new ImageIcon ("cartesCSHD/bluegreencrisscross.jpg") ;
      dos = new JLabel (iconeDos) ;
      dos.setSize (face.getSize ()) ;
      add (dos) ;
      dos.setLocation (0, 0) ;
      setOpaque (false) ;
      setSize (face.getSize ()) ;
      setPreferredSize (getSize ()) ;
    }

	public void setFaceVisible (boolean faceVisible) {
		face.setVisible (faceVisible) ;
    }

   public final CCarte getControle () {
       return (controle) ;
   }

    public void paint (Graphics g) {
	super.paint (g) ;
	g.drawRect (0, 0, getWidth () - 1, getHeight () - 1) ;
    }

    public ImageIcon getIcone () {
	return (icone) ;
    }

    public static int largeur ;
    public static int hauteur ;

    public static void initDimensions () {
	ImageIcon icone = new ImageIcon ("cartesCSHD/1C.gif") ;
	largeur = icone.getIconWidth () ;
	hauteur = icone.getIconHeight () ;
    }

   /*public static void main (String args []) {
      initDimensions () ;
      JFrame f = new JFrame ("Test PCarte") ;
      f.getContentPane ().add (new PCarte ("1C")) ;
      f.addWindowListener (new WindowAdapter () {
	    public void windowClosing (WindowEvent e) {
	       System.exit (0) ;
	    }
	 }) ;
      f.pack () ;
      f.setVisible (true) ;
   }*/

}

//-------------------------------------------------------------------------------------
